﻿using System;
using System.Collections;
using System.Collections.Generic;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using Kiiro.SiteDefinition.Core;
using Kiiro.SiteDefinition.ControlTemplates;
using Kiiro.Common.Utility;
using Microsoft.SharePoint;
using Microsoft.SharePoint.Utilities;

namespace Kiiro.SiteDefinition.CustomListPages
{
    public partial class Lists : BasePage
    {
        protected void Page_Load ( object sender, EventArgs e )
        {
            if ( !IsPostBack )
            {
                litTitle.Text = "Lists";
                if ( KiiroMaster.V2Header.Project != null && !string.IsNullOrEmpty ( KiiroMaster.V2Header.Project.Title ) )
                {
                    litTitle.Text = KiiroMaster.V2Header.Project.Title + " - Lists";
                }

                using ( SPWeb web = SPHelpers.GetWeb ( SiteCollectionId, ServerRelativeUrl ) )
                {
                    if ( CurrentUser.Groups.Contains ( KiiroGroup.PortalMember ) )
                    {
                        string html = "<li><a href='{0}/AllCustomItems.aspx'>{1}</a><span> &mdash; </span>{2}</li>";

                        foreach ( SPList list in web.Lists.Cast<SPList> ( ).Where ( x => x.BaseTemplate.ToString ( ) == "50008" ) )
                        {
                            litListNames.Text += string.Format ( html,
                                list.RootFolder.Url,
                                SPHelpers.ConvertHtmlToKiiroSafeText ( list.Title ),
                                SPHelpers.ConvertHtmlToKiiroSafeText ( list.Description ) );
                        }
                    }
                }
            }
        }
    }
}

/*************************************************************************
 * 
 * $Log: /Internal Projects/Kiiro/Kiiro.SiteDefinition/12/TEMPLATE/FEATURES/Kiiro.CustomListPages/Lists/Lists.aspx.cs $
 * 
 * 9     1/06/10 12:39p Camerons
 * 
 * 8     6/11/09 7:34p Camerons
 * 
 * 7     10/26/09 9:55a Adamw
 * Case 348
 * 
 * 6     30/09/09 4:08p Camerons
 * Update all links that point to UserPages, pass User.SPUserId as the
 * ItemId so that we can safely run GetOrCreateUser
 * 
 * 5     17/08/09 11:07a Camerons
 * Added check-in comments section
 * 
 ************************************************************************/